<?php
namespace app\admin\controller;

use app\common\controller\Back;

class Route extends Back
{
    protected function initialize()
    {
        parent::initialize();
    }
    
    public function index()
    {
        $this->assign('list', config('route.'));

        $this->assign($this->site);

        return $this->fetch();
    }

    public function save()
    {
        $post = input('post.');
        //批量删除
        foreach($post['delete'] as $key=>$value){
            dump($value);
            unset($post['url'][$value]);
        }
        //批量修改
        $routes = [];
        foreach($post['url'] as $key=>$value){
            array_push($routes,[$value,$post['path'][$key]]);
        }
        //保存配置
        $this->configSave('./config/route.php', $routes, 'admin/route/index');
    }
}